#ifndef MDXSERVER_H
#define MDXSERVER_H

#include <QObject>
#include "server.h"
#include <QtSql/QtSql>



#define ERR_SESSCLRERR_ID 4
#define ERR_SESSCLRERR "error clear sessions"
#define ERR_SQLERR_ID 3
#define ERR_SQLERR "interal server error"
#define ERR_PARAMSCOUNT_ID 1
#define ERR_PARAMSCOUNT "parameters count is error"
#define ERR_LOGON_ID 2
#define ERR_LOGON "login or password is incorrect"


class MDxserver : public QObject
{
    Q_OBJECT
    xmlrpc::Server * server;
    int port;
    int session_ttl;
    QSqlDatabase db;
    QString sqlsafe(const QString & str);
    bool clearOldSessions();
public:
    explicit MDxserver(QObject *parent = 0);
    void setPort(int);
    void setBase(const QString & addr, const QString & user, const QString & pass, const QString & dbname, int port=3306);
    void setSessionTtl(int sec);
    void start();

    
signals:
    void sigLog(const QString module, int loglevel, const QString logtext );
    
public slots:
private slots:
    void slotProcessRequest( int id, QString methodName, QList<xmlrpc::Variant> parameters);
    
};

#endif // MDXSERVER_H
